import {
    Body,
    Controller,
    Del,
    File,
    Get,
    Inject,
    Param,
    Post,
    Put,
    Query,
  } from '@midwayjs/core';
import { SampleService } from '../service/sameInfo.service';
import { DPModelInfoQueryDto } from '../dto/SampleInfo.dto';

@Controller('/sample')
export class SampleController {
  @Inject()
  sampleService: SampleService;

  // 查询样本信息
  @Post('/query', { summary: '查询样本信息' })
  async getSamples(@Body() query: DPModelInfoQueryDto) {
    const result = await this.sampleService.findSamples(query);
    return result;
  }

  // 添加样本信息
  @Post('/add', { summary: '添加样本信息' })
  async addSample(@Body() params: any) {
    const result = await this.sampleService.addSample(params);
    return result;
  }

  // 删除样本信息
  @Del('/delete/:id', { summary: '删除样本信息' })
  async deleteSample(@Param('id') id: string) {
    const result = await this.sampleService.deleteSample(Number(id));  // ID 转换为数字
    return result;
  }

  // 批量更新样本类型
  @Put('/batch-update', { summary: '批量更新样本类型' })
  async batchUpdateSampleType(@Body() body: { sampleType: string, sampleIds: number[] }) {
    const result = await this.sampleService.batchUpdateSampleType(body.sampleType, body.sampleIds);
    return result;
  }
}
